<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>订单列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/style/admin.css" media="all">
	<link rel="stylesheet" href="/style/list.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
							<!--<div class="layui-input-inline" style="width:100px;">-->
                                <!--<select name="orderStatus" id="orderStatus"  lay-verify="required" lay-filter="select1">-->
                                    <!--<option selected="selected" value="0">订单状态</option>-->
                                    <!--<option value="701">待付款</option>-->
                                    <!--<option value="702">待发货</option>-->
                                    <!--<option value="703">待收货</option>-->
                                    <!--&lt;!&ndash;<option value="704">售后</option>&ndash;&gt;-->
                                    <!--<option value="705">已完成</option>-->
                                    <!--<option value="706">已关闭</option>-->
                                    <!--<option value="707">已退款</option>-->
                                <!--</select>-->
                            <!--</div>-->
                            <!--<div class="layui-input-inline" style="width:100px;">-->
                                <!--<select name="payStatus" id="payStatus" lay-filter="select2">-->
                                    <!--<option selected="selected"  value="0">支付状态</option>-->
                                    <!--<option value="801">待支付</option>-->
                                    <!--<option value="802">已支付</option>-->
                                <!--</select>-->
                            <!--</div>-->
                            <!--<div class="layui-input-inline"style="width:100px;">-->
                                <!--<select name="deliveStatus" id="deliveStatus" lay-filter="select3">-->
                                    <!--<option selected="selected"  value="0">发货状态</option>-->
                                    <!--<option value="901">已发货</option>-->
                                    <!--<option value="902">待发货</option>-->
                                <!--</select>-->
                            <!--</div>			-->

                <div class="layui-inline">
                    <label class="layui-form-label">订单编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="orderNo" id="orderNo" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">会员编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="userNo" id="userNo" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
				<div class="layui-inline">
                    <label class="layui-form-label">收货姓名</label>
                    <div class="layui-input-block">
                        <input type="text" name="logName" id="logName" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
				<div class="layui-inline">
                    <label class="layui-form-label">收货手机号</label>
                    <div class="layui-input-block">
                        <input type="text" name="phone" id="phone" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-search" onclick="SelectData()">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                    <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-user-back-search" onclick="qingkong()">
                        <i class="layuiadmin-button-btn">清空条件</i>
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <div style="padding-bottom: 10px;display:none">
                <button class="layui-btn layuiadmin-btn-admin" data-type="add" onclick="WinOpenAdd();" >添加</button>
				<button class="layui-btn layuiadmin-btn-admin" data-type="pay" onclick="WinOpenPay();">支付检查</button>
            </div>

            <table class="layui-hide" id="test"></table>
			
			<script type="text/html" id="barNo">
                <a id="order{{d.orderId}}" onmouseenter="show('{{d.orderId}}');" onmouseleave="layer.close(tip_index);">{{d.orderNo}}</a>

            </script>
			
			<script type="text/html" id="barStatus">
                <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail"  onclick="WinOpenEdit1({{d.orderId}})">{{d.orderStatusname}}</a>
            </script>

            <script type="text/html" id="barAddr">
                {{d.addressAll}} {{d.detailAddr}}
                <!--{{d.addressAll}}-->
            </script>
			
			<!--<script type="text/html" id="barLogistical">-->
                <!--<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="detail"  onclick="WinOpenEdit({{d.orderId}})">{{d.logisticalTypeName}}</a>-->
            <!--</script>-->

            <script type="text/html" id="barDemo">
                <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail"  onclick="WinOpenShow({{d.orderId}},'{{d.usernoName}}')">查看</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick="WinOpenRefund({{d.orderId}})">退款</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="detail" onclick="WinOpenRefundBH({{d.orderId}})">驳回</a>
            </script>

        </div>
    </div>
</div>
<script src="/layui/layui.js"></script>
<script src="/layui/jquery.min.js"></script>
<style>
    .layui-body{overflow-y: scroll;}	
	.laytable-cell-1-orderId{width:50px;}
</style>
<script type="text/javascript">
    var tip_index = 0;
    function show(e){
        var productInfo="";
        $.ajax({
            url: '/goods?url=Order%2FgetDetails&orderId='+e+'',
            type: 'post',
            dataType: 'json',
            contentType: 'application/json',
            async: false,
            success: function(data){
                //$("#orderNo").html(JSON.stringify(data));return;
                productInfo +="<div id='orderGoos'+e><ul>";
                if(data.code=="000000"){
                    $.each(data.data.adminOrderDetails, function(i, item){
                        productInfo +="<li style='clear:both; height:80px; width:300px;' class='productli'>";
                        productInfo +="<img style='width:100px;height:65px; float:left; margin-right:5px' class='productimg' src='"+item.guigePic+"'>" +
                            "<div style='color:#000; float:left;' class='productdiv'>"+item.productName+item.guigeName+"<br>数量:"+item.productCount+"<br>价格:"+item.price+"</div>";
                        productInfo +="<li class='productli'>";
                    });
                    productInfo +="<li style='clear:both;'></li></ul></div>";
                }
            }
        });

        // tip_index = layer.tips($("#orderGoos"+e).html(), "#order"+e, {tips: [2, '#ddd'],time: 0,area: ['300px', 'auto'],});
        tip_index = layer.tips(productInfo, "#order"+e, {tips: [2, '#ddd'],time: 0,area: ['300px', 'auto'],});
    }
    function qingkong() {
        $("#orderNo").val("");
        $("#userNo").val("");
        $("#logName").val("");
        $("#phone").val("");
        usernoId=0;
    }
    var usernoId=0;
    $("#userNo").blur(function () {
        var urls="/user?url=User%2FgetUserAndNoInfo&userNo="+$("#userNo").val();
        var url = "/wap/getUserAndNoInfo?userNoId="+$("#userNo").val();
        $.ajax({
            url: urls,
            type: "GET",
            async:false,
            dataType: "json", //指定服务器返回的数据类型
            success: function(result) {
                if(result.code=="000000"){
                    if(result.data!=null){
                        usernoId=result.data.id;
                    }else {
                        usernoId=-1;
                    }
                }
            }
        });
    });
</script>
<script>
    var table;
    layui.use('table', function(){
        table = layui.table
            ,form = layui.form;

        table.render({
            elem: '#test'
            ,url:'/goods?url=Order%2FRefundList'
			,cellMinWidth:80
            ,cols: [[
                {type:'numbers'}
                ,{type: 'checkbox'}
                ,{field:'orderNo',width:200,title:'订单编号', templet: '#barNo', unresize: true}
                ,{field:'orderMoney', title:'订单金额'}
				,{field:'realPay', title:'实际支付'}
				,{field:'orderStatus',title:'订单状态', templet: '#barStatus', unresize: true}//orderStatusName
                ,{field:'usernoName', title: '用户编号'}
				// ,{field:'logname', title: '收货姓名'}
                // ,{field:'phone',width:150, title: '收货电话'}
                // ,{field:'addressAll',width:300, title: '收货地区', templet: '#barAddr', unresize: true}
				// ,{field:'logisticalTypeName', title: '物流类型', templet: '#barLogistical', unresize: true}
                ,{field:'pOrderTime',width:200,title: '下单时间'}
                ,{field:'returnReason',width:300, title: '退款原因'}
                ,{field:'applyTime',width:200, title: '退款申请时间'}
                ,{field:'order', title:'编辑', templet: '#barDemo', unresize: true}
            ]]
            ,page: true
            ,id: 'testReload'
        });

        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });
    });

	/*添加订单*/
	function WinOpenAdd(){
		window.parent.WinOpenAdd(this,"/order/orderAdd","添加订单",1800,700,1);
	}
	
	/*编辑订单状态*/
	function WinOpenEdit1(orderId){
		// window.parent.WinOpenEdit(this,"/order/order/orderStatus.html?orderId="+orderId,"修改订单状态",340,350,1);
	}
	
	/*编辑订单物流*/
	function WinOpenEdit(orderId){
		window.parent.WinOpenEdit(this,"/order/order/orderLogistical.html?orderId="+orderId,"修改订单物流",500,650,1);
	}
	

	function WinOpenRefund(orderId){
        layer.confirm("是否退款？", {
            btn: ["确定","取消"] //按钮
        }, function(){

            var url = '/goods?url=Order%2FRefund&orderId='+orderId;
            $.ajax({
                url: url,
                type: "POST",
                async:false,
                dataType: "json", //指定服务器返回的数据类型
                success: function(result) {
                    if(result.code=="000000"){
                        alert("退款成功!")

                    }else {
                        alert("退款失败!"+result.errorDetail)
                    }
                }
            });
            layer.closeAll('dialog');

        }, function(){

        });

		//window.parent.WinOpenEdit(this,"/order/order/orderDel.html?orderId="+orderId,"删除订单",340,300,1);
	}
    function WinOpenRefundBH(orderId){
        layer.confirm("是否驳回？", {
            btn: ["确定","取消"] //按钮
        }, function(){

            var url = '/goods?url=Order%2FRefundBH&orderId='+orderId;
            $.ajax({
                url: url,
                type: "POST",
                async:false,
                dataType: "json", //指定服务器返回的数据类型
                success: function(result) {
                    if(result.code=="000000"){
                        alert("驳回成功!")

                    }else {
                        alert("驳回失败!"+result.errorDetail)
                    }
                }
            });
            layer.closeAll('dialog');

        }, function(){

        });
    }

	function WinOpenShow(orderId,usernoName){
		window.parent.WinOpenShow("/order/order/orderShow.html?orderId="+orderId+"&usernoName="+usernoName,"查看订单详情",1440,900);
	}
	
    function SelectData() {
        //数据刷新
		var orderStatus=$('#orderStatus').val();
		var orderNo=$('#orderNo').val();
        var logName = $('#logName').val();
		var phone=$('#phone').val();
		var url="/goods?url=Order%2FRefundList&";
		if(orderStatus>0){
			url+="orderStatus=704&";
		}
		if(orderNo!=""){
			url+="orderNo="+orderNo+"&";
		}
		if(usernoId!=0){
			url+="usernoId="+usernoId+"&";
		}
		if(logName!=""){
			url+="logName="+logName+"&";
		}
		if(phone!=""){
			url+="phone="+phone+"&";
		}

        //执行重载
        table.reload('testReload', {
            url:url,
            page: {
                curr: 1 //重新从第 1 页开始
            }
        });
    }
</script>


</body>
</html>